﻿using System;
using HelpersDotNet.DomainDrivenDesign.Infrastructure.DomainBase;
using System.Reflection;

namespace HelpersDotNet.DomainDrivenDesign.Extensions
{
    public static partial class Extensions
    {
        public static object ToContract(this IEntity entity)
        {
            string methodName = string.Format("To{0}Contract", entity.GetType().Name);
            MethodInfo method = typeof(Extensions).GetMethod(methodName);
            return method.Invoke(null, new object[] { entity });
        }
    }
}